package com.sukaiyi.giteeideaplugin.utils;


import java.lang.reflect.Field;

/**
 * @author sukaiyi
 * @date 2020/07/08
 */
public class ReflectUtils {

    private ReflectUtils() {

    }

    public static Object getStaticFieldValue(String clazzName, String fieldName) {
        try {
            Class<?> clazz = Class.forName(clazzName);
            Field field = clazz.getField(fieldName);
            return field.get(null);
        } catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) {
            // it`s doesn't matter if there is no such class
        }
        return null;
    }

    public static Object getStaticFieldValue(Class<?> clazz, String fieldName) {
        try {
            Field field = clazz.getField(fieldName);
            return field.get(null);
        } catch (NoSuchFieldException | IllegalAccessException ignored) {
            // it`s doesn't matter if there is no such class
        }
        return null;
    }

}
